package ja12resttemplate.util;

import java.util.Collection;
import java.util.Map;

/**
 * 常用对象的为空判断
 */
public class AssertUtil {
    public AssertUtil() {
    }

    public static boolean isVal(String val) {
        return val != null && !val.isEmpty();
    }

    public static boolean isVal(Integer val) {
        return val != null && val != 0;
    }

    public static boolean isVal(Long val) {
        return val != null && val != 0L;
    }

    public static boolean isVal(Object val) {
        if (val == null) {
            return false;
        } else {
            return !(val instanceof String) || !val.toString().isEmpty();
        }
    }

    public static boolean isVal(Map<?, ?> val) {
        return val != null && !val.isEmpty();
    }

    public static boolean isVal(Collection<?> val) {
        return val != null && !val.isEmpty();
    }

    public static boolean isVal(byte[] val) {
        return val != null && val.length > 0;
    }
}
